import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../dd_core/dd_config.dart';
import '../../../dd_core/dd_log_service.dart';
import '../../../r.dart';
import '../controllers/dd_publish_controller.dart';
import '../views/dd_publish_background.dart';
import 'dd_publish_second_page.dart';

class DDPublishPage extends StatefulWidget {
  const DDPublishPage({Key? key}) : super(key: key);

  @override
  State<DDPublishPage> createState() => _DDPublishPageState();
}

class _DDPublishPageState extends State<DDPublishPage> {
  DDPublishController _controller = DDPublishController();

  @override
  Widget build(BuildContext context) {
    return GetBuilder<DDPublishController>(
        init: _controller,
        initState: (state) {
          DDLogService().ddGa(page: "pushlish_page");
        },
        dispose: (state) {},
        builder: (controller) {
          return Scaffold(
            backgroundColor: Color(0xFFE7F6FC),
            body: SafeArea(
              top: false,
              child: Container(
                  decoration: BoxDecoration(
                      image: DecorationImage(
                    image: AssetImage(R.assetsImagesPublish1),
                    fit: BoxFit.fill,
                  )),
                  child: Stack(
                    children: [
                      Positioned.fill(
                        child: DDPublishBackground(),
                      ),
                      Positioned.fill(
                          child: SingleChildScrollView(
                              physics: ClampingScrollPhysics(),
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                children: [
                                  SizedBox(
                                    height: 140,
                                  ),
                                  GestureDetector(
                                    onTap: () {
                                      DDRoutesConfig.push(DDPublishSecondPage(),
                                          routeName: "/publishSecondPage");
                                    },
                                    child: Padding(
                                      padding: const EdgeInsets.only(
                                          top: 16.0, left: 18),
                                      child: Image.asset(
                                        R.assetsImagesPublish3,
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                  ),
                                  Padding(
                                    padding: EdgeInsets.only(
                                        top: 10,
                                        right:
                                            70 * DDScreenUtil.getWidthRatio(),
                                        left:
                                            70 * DDScreenUtil.getWidthRatio()),
                                    child: CupertinoButton(
                                      onPressed: () {
                                        DDRoutesConfig.push(
                                            DDPublishSecondPage(),
                                            routeName: "/publishSecondPage");
                                      },
                                      child: Text(
                                        'Click ‘post’ to record your fencing moment!',
                                        textAlign: TextAlign.center,
                                        style: TextStyle(
                                          color: Color(0xFFFFFFFF),
                                          fontSize: 16,
                                          letterSpacing: 0,
                                          fontWeight: FontWeight.bold,
                                        ),
                                      ),
                                    ),
                                  ),
                                ],
                              ))),
                    ],
                  )),
            ),
          );
        });
  }
}
